<template>
  <div class="app-container">
    <panel-group :pdata="pdata" @handlego="handlego"/>
    <el-table v-loading="listLoading" :data="list" border fit highlight-current-row style="width: 100%">
      <el-table-column align="center" label="ID" show-overflow-tooltip>
        <template slot-scope="scope">
          <span>{{ scope.row.id }}</span>
        </template>
      </el-table-column>

      <el-table-column  align="center" label="姓名" show-overflow-tooltip>
        <template slot-scope="scope">
          <span>{{ scope.row.name }}</span>
        </template>
      </el-table-column>

      <el-table-column  align="center" label="联系方式" show-overflow-tooltip>
        <template slot-scope="scope">
          <span>{{ scope.row.mobile }}</span>
        </template>
      </el-table-column>

      <el-table-column   label="求职岗位" show-overflow-tooltip>
        <template slot-scope="scope">
          <span>{{ scope.row.postTypeName?scope.row.postTypeName:'暂无' }}</span>
        </template>
      </el-table-column>

      <el-table-column class-name="status-col" label="E力值" width="110" show-overflow-tooltip>
        <template slot-scope="scope">
          <span>{{scope.row.ePower}}</span>
        </template>
      </el-table-column>

      <el-table-column  label="激活状态" width="160" show-overflow-tooltip>
        <template slot-scope="scope">
          <span>{{ scope.row.active === 1 ? '已激活' : '未激活' }}</span>
        </template>
      </el-table-column>

      <el-table-column  label="求职状态" width="120" show-overflow-tooltip>
        <template slot-scope="scope">
          <span>{{ scope.row.jobStatus | changeJobStatus}}</span>
        </template>
      </el-table-column>

      <el-table-column  label="添加时间" width="120" show-overflow-tooltip>
        <template slot-scope="scope">
          <span>{{ scope.row.createTime }}</span>
        </template>
      </el-table-column>

      <el-table-column align="center" label="操作" show-overflow-tooltip>
        <template slot-scope="scope">
            <el-button  type="success" size="small" icon="el-icon-circle-check-outline" @click="del(scope.row.id, scope.row.name)">删除</el-button>
        </template>
      </el-table-column>

    </el-table>
  </div>
</template>

<script>
  import { fetchList } from '@/api/web/talent'
  import PanelGroup from '@/components/PanelGroup'
  export default {
    components: {
      PanelGroup
    },
    data() {
      return {
        list: null,
        listLoading: false,
        listQuery: {
          pageNo: 1,
          limit: 15,
          query: "",
          type:"own"
        },
        pdata:{
          link:'post'
        }
      }
    },
    mounted() {
      this.getList()
    },
    methods: {
      getList() {
        // this.listLoading = true
        fetchList(this.listQuery,"").then(response => {
          this.list = response.page.records
          this.listLoading = false
        })
      },
      handlego() {
        this.$router.push('/post/'+this.$route.meta.id)
        console.log('personnel/post/'+this.$route.meta.id)
      },
      del (id, name) {
        this.$confirm('删除人才：'+ name +', 是否继续?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          this.$fetch(this.$api.delTalent + id).then(res => {
            if (res.code === 0) {
              this.$message.success('删除成功')
              this.getList()
            }
          })
        }).catch(() => {
          this.$message({
            type: 'info',
            message: '已取消删除'
          });          
        });
      }
    },
    filters: {
      changeJobStatus (el) {
        if (el === 'work') {
          return '在职-暂不考虑'
        } else if (el === 'planing') {
          return '计划跳槽'
        } else if (el === 'hunting') {
          return '离职-随时到岗'
        } else if (el === 'holiday') {
          return '休假'
        } else {
          return '在职-暂不考虑'
        }
      }
    }
  }
</script>

